/*
 * @Autor: CQJ
 * @Date: 2022-08-16 10:23:33
 * @LastEditors: CQJ
 * @LastEditTime: 2022-08-16 14:19:01
 * @Description: 
 */
import { defineStore } from 'pinia';
import { SettingState } from '@/types/store/setting';
import defaultSettings from '../../settings';

const { showSettings, sidebarLogo } = defaultSettings;

export const useSettingStore = defineStore({
    id: 'setting',
    state: (): SettingState => ({
        showSettings: showSettings,
        sidebarLogo: sidebarLogo,
    }),
    actions: {
        async changeSetting(payload: { key: string; value: any }) {
            const { key, value } = payload;
            switch (key) {
                case 'showSettings':
                    this.showSettings = value;
                    break;
                case 'sidebarLogo':
                    this.sidebarLogo = value;
                    break;
                default:
                    break;
            }
        },
    },
});

export default useSettingStore;
